/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 adv_actor_action.h

	$Header: /heroes4/adv_actor_action.h $

	$NoKeywords: $

 ************************************************************************/

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#include "precompiled.h"
#pragma warning( disable: 4786 )

#include "adv_actor_action.h"

#include <cassert>
#include "enum_operations.h"

// ------------------------------------------------------------------------------
// Unnamed namespace
// ------------------------------------------------------------------------------

namespace
{
	// ------------------------------------------------------------------------------
	// ------------------------------------------------------------------------------
	struct t_adv_actor_action_properties
	{
		std::string		name;

		t_adv_actor_action_properties( std::string const & new_name ) : name( new_name ) {}
	};

	inline t_adv_actor_action_properties const & get_adv_actor_action_properties( t_adv_actor_action_id action_id )
	{
		assert( action_id >= 0 && action_id < k_adv_actor_action_count );
		static t_adv_actor_action_properties const k_adv_actor_action_properties_array[ k_adv_actor_action_count ] =
		{
			t_adv_actor_action_properties( "wait" ),
			t_adv_actor_action_properties( "fidget" ),
			t_adv_actor_action_properties( "prewalk" ),
			t_adv_actor_action_properties( "walk" ),
			t_adv_actor_action_properties( "postwalk" ),
			t_adv_actor_action_properties( "attack" ),
		};

		return k_adv_actor_action_properties_array[ action_id ];
	}

} // Unnamed namespace

// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
std::string const & get_adv_action_name( t_adv_actor_action_id action )
{
	return get_adv_actor_action_properties( action ).name;
}

t_adv_actor_action_id get_adv_action( std::string const& keyword )
{
	if (stricmp( keyword.c_str(), "stand" ) == 0)
		return k_adv_actor_action_wait;
	t_adv_actor_action_id action;

	for (action = t_adv_actor_action_id(0); action < k_adv_actor_action_count; 
	     enum_incr( action ))
	{
		if (stricmp( keyword.c_str(), get_adv_action_name( action ).c_str() ) == 0)
			return action;
	}
	return k_adv_actor_action_count;
}
